<!DOCTYPE html>
<html lang="en">

<head>
    <title>战队PK</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
    <script src="../../js/jquery-3.2.1.min.js"></script>
    <link rel="stylesheet" href="//unpkg.com/vue-ydui/dist/ydui.rem.css">
<script src="//unpkg.com/vue-ydui/dist/ydui.flexible.js"></script>

<!-- 引入Vue2.x -->
<script src="//vuejs.org/js/vue.min.js"></script>
<!-- 引入组件库 -->
<script src="//unpkg.com/vue-ydui/dist/ydui.rem.js"></script>
    <link rel="stylesheet" href="../../css/public.css">
    <style>
        .register_bg {
            position: absolute;
            left: 0;
            top: 0;
            bottom: 0;

            right: 0;
            background: url('../../images/reg/bg.png') center no-repeat;
            background-size: 100% 100%;
            z-index: 1;
        }

        .home_zhangdui_nav {
            overflow: hidden;
            background: #021349 url('../../images/reg/back.png') 10px center no-repeat;
            background-size: .5rem;
            font-size: 0.4rem;
        }

        .guese-logo {
            margin-top: 50px;
            height: 180px;
        }

        /* .guese-logo img {
            width: auto;
        } */

        .VIPNumber {
            width: 58%;
            margin: 0 auto;
            height: 37px;
            background: url(../../images/home/bg_team_issue_warname.png) no-repeat;
            background-size: 100% 100%;
            position: relative;
        }

        .VIPNumber_p {
            text-align: center;
            color: #FFCD29;
            font-size: 0.4rem;
            line-height: 37px;
        }

        .VIPNumber_img {
            max-width: .35rem;
            position: absolute;
            right: 15%;
            top: 10px;
        }

        .details {
            width: 70%;
            margin: 0 auto;
            background: url(../../images/home/bg_team_issue_message.png) no-repeat;
            background-size: 100% 100%;
            margin-top: 20px;
        }

        .details ul {
            width: 100%;
            padding-top: 16px;
            padding-bottom: 16px;
            padding-right: 5%;
        }

        .details ul li {
            width: 100%;
            margin-bottom: 16px;
        }

        .left {
            width: 40%;
            display: inline-block;
            text-align: right;
            font-size: .35rem;
            color: #999BC7;
        }

        .right {
            width: 60%;
            font-size: .4rem;
            padding-left: 2%;
            color: #D0D2F7;

        }

        .details select {
            width: 45%;
            box-sizing: border-box;
            padding-left: .1rem;
            color: #D0D2F7;
            background: #15095e;
            border: 0;
            border-bottom: 1px solid #3B3678;
            padding-bottom: .1rem;
        }
option{
    font-size: .3rem;
}
        .details input {
            width: 47%;
            box-sizing: border-box;
            padding-left: .1rem;
            height: 28px;
            border: 0;
            color: #FFCD29;
            background: #15095e;
            border-bottom: 1px solid #3B3678;
  
        }

        input#money {
            max-width: auto;
            font-size: .3rem;
        }

        input::-webkit-input-placeholder {

            color: #7069B3;
        }

        .money_right {
            width: 60%;
            font-size: .4rem;
            padding-left: 2%;
            color: #FFCD29;
        }

        .publish_btn {
            width: 74%;
            height: 60px;
            background: url(../../images/home/btm_home_team_challenge_room_challenge.png) no-repeat;
            background-size: 100% 100%;
            border: none;
            margin-top: 20px;
            margin-left: 13%;
            color: #1D1104;
            text-align: center;
            font-size: .4rem;
        }

        .notice {
            text-align: center;
            font-size: .3rem;
            /* margin-bottom: 20px; */
            color: #FF4343;
        }
        .roomNum {
            width: 50%;
            border: 0;
            color: #FFCD29;
            background: #15095e;
            font-size: .3rem;
        }

        input#startTime {
            display: block;
            margin: auto;
            background: none;
            margin-left: 17%;
        }

        .gg {
            position: relative;
        }

        select {
            background: rgba(0, 0, 0, 0);
            opacity: 0;
            position: relative;
            z-index: 999
        }

        .fugai {
            position: absolute;
            height: 100%;
            width: 100;
            width: 45%;
            background: url(../../images/home/selectBg.png ) center right no-repeat;
            background-size: 15%;

            top: 0;
            right: 10%;
            z-index: 1;
            font-size: .35rem;
            color: #D0D2F7;
            border-bottom: 1px solid #3B3678;
            line-height: .8rem;
        }
        .gametime {
            overflow: hidden;
        }
        .gametime .left {
            float: left;
        }
        .gametime .right {
            margin-left: 42%;
            height: 28px;
            line-height: 28px;
        }
        .yd-datetime span{
            color: #000;
            
        }
    </style>
</head>

<body>

    <div class="register_bg" id="app">
        <div class="home_zhangdui_nav">
            <span class="goBack"></span>
            <span>发布战局</span>
        </div>

        <div class="guese-logo">
            <img src="../../images/home/bg_home_issue _ailin.png" alt="">

        </div>
        <div class="VIPNumber">
            <p id="VIPNumber_p" class="VIPNumber_p">
                <input class="roomNum" type="text" name="" value="VIP123456" readonly>
            </p>
            <img id="copy" src="../../images/home/icon_copy.png" class="VIPNumber_img">
        </div>
        <div class="details">
            <ul>
                <li class="gg">
                    <span class="left">房间模式:</span>
                    <span class="right ">
                        <select name="roomNumber" id="roomNumber" class="roomNumber">
                            <option value="0">大厅房间</option>
                            <option value="1">加密房间</option>
                        </select>
                    </span>
                    <div id="roomNum1" class="fugai">大厅房间</div>
                </li>
                <li class="gg">
                    <span class="left">参战人数:</span>
                    <span class="right ">
                        <select name="peopleNumber" id="peopleNumber" class="peopleNumber">
                            <option value="选择人数">选择人数</option>
                            <option value="1vs1">1vs1</option>
                            <option value="11vs1">3vs3</option>
                            <option value="11vs1">5vs5</option>
                        </select>
                    </span>
                    <div id="peopelNum" class="fugai">选择人数</div>

                </li>
                <li>
                    <span class="left">下注金额:</span>
                    <span class="money_right">
                        <input id="money" type="number" placeholder="请输入金额" required>
                    </span>
                </li>
                <li class="gg">
                    <span class="left">授权通道:</span>
                    <span class="right">
                        <select name="peopleNumber" id="channel" class="peopleNumber">
                            <option value="选择品牌">授权通道</option>
                            <option value="选择品牌1">微信</option>
                            <option value="选择品牌2">QQ</option>
                        </select>
                    </span>
                    <div id="pindao" class="fugai">授权通道</div>
                </li>
                <li class="gg lastone">
                    <span class="left">等待时效:</span>
                    <span class="right">
                        <select name="peopleNumber" id="waitTime" class="peopleNumber">
                            <option value="选择人数">等待时间</option>
                            <option value="1h">1h</option>
                            <option value="2h">2h</option>
                            <option value="3h">3h</option>
                        </select>
                    </span>
                    <div id="ddsj" class="fugai">等待时间</div>
                </li>
                <li style="margin-bottom:0" class="gametime">
                    <span class="left">开始时间:</span>
                    <div class="right">
                        <yd-datetime style=" font-size: .3rem;" v-model="datetime0"></yd-datetime>
                    </div>
                </li>
            </ul>
        </div>
        <button class="publish_btn" @click.native='pubilsh'>发布战局</button>
        <p class="notice">*战局手续费：<span class="warfee" id="warfee"></span>%</p>
    </div>
    <script src="../../js/public.js"></script>
    <script src="../../js/jquery-3.2.1.min.js"></script>
    <script>
        new Vue({
            el: '#app',
            data() {
                return {
                    datetime0: '2018-1-1 00:00'
                }
            },
            methods: {
              
            },
            created () {
                var date = new Date();
                var year = date.getFullYear(); 
                var mon  = date.getMonth()+1; 
                var da   = date.getDate(); 
                var h    = date.getHours(); 
                var m    = date.getMinutes(); 
                var d    = document.getElementById('Date'); 
           
                this.datetime0 = year+'-'+mon+'-'+da+' '+h+':'+m;
            }
        })
    </script>
    <script>
        $('.goBack').click(function(){
            window.history.go(-1)
            console.log('this')
        })
        $(function () {
            let fdCreateName,
            roomNum,
            fees

            $.post(userInfoUrl, (res) => {
                fdCreateName = res.obj.fdNickname
                console.log(res)
                
            })
            $.post(roomNumUrl, (res) => {
                roomNum = res.fd_room_no
                $('.roomNum').val(roomNum)
                console.log(res)

            })
            //手续费
            $.post(warfeeUrl, (res) => {
                fees = res.obj.fdFees * '100';
                // alert(fees)
                $('#warfee').text(fees)
                console.log(res)

            })
            $('.flatpickr-input').css({
                'display': 'block',
                'margin': 'auto',
                "margin-bottom": "10px",
                // "margin-left": "20%",
                'width': '80%',
                'background': 'none'
            })
            $('#startTime').val('请选择游戏开始时间')
            $('#roomNumber').change(function () {
                $('#roomNum1').text($('#roomNumber option:selected').text())
            })
            $('#peopleNumber ').change(function () {
                $('#peopelNum').text($('#peopleNumber option:selected').text())
            })

            $('#channel ').change(function () {

                $('#pindao').text($('#channel option:selected').text())
            })
            $('#waitTime ').change(function () {

                $('#ddsj').text($('#waitTime option:selected').text())
            })


            //复制房间号
            $('#copy').click(function () {
                $('.roomNum').trigger('select');
                document.execCommand('copy');
                alert("复制成功！");
            })
            
            $('.publish_btn').click(function(){
                var vl = $('#money').val();
                if(vl == '' || vl <= 0){
                    alert('请输入不小于0的下注金额!');
                    return;
                }
                const fdWarName = roomNum,
                    fdWarMode = $('#roomNumber').val(),
                    fdNum =$('#peopleNumber option:selected').text(),
                    fdAmount = $('#money').val(),
                    fdChannel = $('#channel option:selected').text(),
                    fdWaitTime = $('#waitTime option:selected').text(),
                    fdStartTime = $('.yd-datetime-input').text(),
                    fdRoomNo = roomNum
                    console.log( fdCreateName)
                if(fdNum == '选择人数'){
                    alert('请选择人数');
                    return ;
                };
                if(fdChannel == '授权通道'){
                    alert('请选择授权通道');
                    return;
                };
                if(fdWaitTime == '等待时间'){
                    alert('请选择等待时间');
                    return;
                }; 
                $.post(publishUrl, {
                    fdWarName,
                    fdWarMode,
                    fdNum,
                    fdAmount,
                    fdChannel,
                    fdWaitTime,
                    fdStartTime,
                    fdRoomNo,
                    fdCreateName
                }, res => {
                    console.log(res)
                    let obj = res.obj
                    if(res.code==500){
                        alert(res.msg)
                    }
                    else{
                        alert(res.msg)
                        // window.location.href='./ModalFrame.html?mode='+fdWarMode;
                        window.location.href='./ModalFrame.html';
                    }
                   
                })
            })
        })
    </script>
</body>

</html>